• RenameFile("OldName","NewName"). This renames a file, keeping it in the same folder (or at the root of the volume). "OldName" is a full pathname, and "NewName" is a replacement for the last component of that path. For instance: put RenameFile("HD:Telecom:capture","session") into err will produce a file called "HD:Telecom:session" if it succeeds.
0 is returned on success, a negative number for an Operating System error, and 1 for a parameter error. See the OsErr handler in the stack script for a suggestion on how to handle this.
-- OsErr: for displaying Operating system error codes returned by
-- Sublaunch, RenameFile, MoveFile and DeleteFile XFCNs.
on OsErr err
-- Translate the most common ones
if err > 0 then -- XFCN convention
put "Parameter error with function" into errstr
else if err is -59 then
put "Problem during rename" into errstr
else if err is -54 then
put "Attempt to open locked file for writing" into errstr